<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>景点订单列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/layuiadmin/style/admin.css" media="all">
    <style>
        #guide_ul li{
            margin-top: 5px;
        }
    </style>
</head>
<body>
<div id="aaa"></div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">景点订单列表</div>
                <div class="layui-card-body">
                    <div class="layui-form-item layui-form">
                     <!--    <div class="layui-inline">
                            <label class="layui-form-label">订单编号</label>
                            <div class="layui-input-block">
                                <input type="text" name="order_sn_"  id="order_sn_"  placeholder="请输入" autocomplete="off" class="layui-input">
                            </div>
                        </div> -->
                       {if !empty($res)}
                        <div class="layui-inline">
                            <label class="layui-form-label">订单编号</label>
                            <div class="layui-input-block">
                                <select name="order_sn" lay-verify="" lay-search id="order_sn_">
                                    <option value="">请选择</option>
                                    {foreach $res as $k=>$v}
                                    <option value="{$v['order_sn']}">{$v['order_sn']}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>
                        {/if}
                        <div class="layui-inline">
                            <label class="layui-form-label">景点名称</label>
                            <div class="layui-input-block">
                                 <select name="order_status_" id="tour_name_">
                                   <option value="">全部</option>
                                     {foreach $tour_name as $k=>$v}
                                       <option value="{$v['tour_name']}">{$v['tour_name']}</option>
                                    {/foreach} 
                                </select>
                            </div>
                        </div>

                        <div class="layui-inline" >
                            <label class="layui-form-label" >订单状态</label>
                            <div class="layui-input-block">
                                <select name="order_status_" id="order_status_">
                                    <option value="">全部</option>
                                    <option value="0">待付款</option>
                                    <option value="1">未出行</option>
                                    <option value="2">取消</option>
                                    <option value="3">待评价</option>
                                    <option value="4">完成</option>
                                </select> </div>
                        </div>
                        <div class="layui-inline">
                          <label class="layui-form-label">下单时间</label>
                          <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="test6" placeholder="  ">
                          </div>
                        </div>
                        <div class="layui-inline">
                            <div class="layui-btn-group test-table-operate-btn">
                                <button class="layui-btn" data-type="searchUserButton">
                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                </button>
                            </div>
                        </div>
                    </div>
                    <table class="layui-hide" id="test-table-operate" lay-filter="test-table-operate">
                    </table>
                    <script type="text/html" id="test-table-operate-barDemo">
                        <a class="layui-btn layui-btn-xs" lay-event="showDetail">详细信息</a> 
                        <a class="layui-btn layui-btn-xs" lay-event="appDetail">评价信息</a> 
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="contentShow" style="display:none;padding: 30px;">
    <p id="consultation"></p>
</div>
<!--添加弹窗-->
 <div id="userDetail" style="display: none;padding:20px;">
    <form class="layui-form" action="" lay-filter="component-form-group"> 

        <div class="layui-form-item"> 
             <div class="layui-inline">
                <label class="layui-form-label">订单信息：</label>
                <div class="layui-input-block"> 
                </div>
            </div>
            <br/>
            <div class="layui-inline">
                <label class="layui-form-label">订单编号：</label>
                <div class="layui-input-block">
                    <input type="text"  id="order_sn" autocomplete="off" class="layui-input">
                </div>
            </div>
           
            <div class="layui-inline">
                <label class="layui-form-label">支付类型：</label>
                <div class="layui-input-block">
                    <input type="text" id="pay_type" autocomplete="off" class="layui-input">
                </div>
            </div> 
        </div>

        <div class="layui-form-item"> 
           <div class="layui-inline">
                <label class="layui-form-label">实付价格：</label>
                <div class="layui-input-block">
                    <input type="text" id='order_price' autocomplete="off" class="layui-input">
                </div>
            </div> 
            <div class="layui-inline">
                <label class="layui-form-label">下单时间：</label>
                <div class="layui-input-block">
                   <input type="text" id="create_time" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>  
         <div class="layui-form-item"> 
           <div class="layui-inline">
                <label class="layui-form-label">订单状态：</label>
                <div class="layui-input-block">
                    <input type="text" id='order_status' autocomplete="off" class="layui-input">
                </div>
            </div>  
        </div>  
        
          <div class="layui-form-item">  
            <div class="layui-inline">
                <label class="layui-form-label">景点信息：</label>
                <div class="layui-input-block"> 
                </div>
            </div>
            <br/>
            <div class="layui-inline">
                <label class="layui-form-label">景点名称：</label>
                <div class="layui-input-block">
                   <input type="text" id="tour_name" autocomplete="off" class="layui-input">
                </div>
            </div> 
              <div class="layui-inline">
                <label class="layui-form-label">门票价格：</label>
                <div class="layui-input-block">
                    <input type="text" id='total_price' autocomplete="off" class="layui-input">
                </div>
            </div>    
        </div>
          <div class="layui-form-item">    
              <div class="layui-inline">
                <label class="layui-form-label">门票张数：</label>
                <div class="layui-input-block">
                    <input type="text" id='ticket_count' autocomplete="off" class="layui-input">
                </div>
            </div>    
            <div class="layui-inline">
                <label class="layui-form-label">门票日期：</label>
                <div class="layui-input-block">
                    <input type="text" id='ticket_date' autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>
      <div class="layui-form-item">  
         <div class="layui-inline">
                <label class="layui-form-label">取票人信息:</label>
                <div class="layui-input-block"> 
                </div>
            </div>
            <br/>
                <div class="layui-inline">
                <label class="layui-form-label">姓名:</label>
                <div class="layui-input-block">
                    <input type="text" id="linkman" autocomplete="off" class="layui-input">
                </div>
            </div>
              <div class="layui-inline">
                <label class="layui-form-label">电话:</label>
                <div class="layui-input-block">
                    <input type="text" id="tel" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>   
    </form>
</div>
<div id="appDetail" style="display: none;padding:20px;">
    <form class="layui-form" action="" lay-filter="component-form-group"> 
       <input type="hidden" id="app_id" name="app_id">
        <div class="layui-form-item">  
            <div class="layui-inline">
                <label class="layui-form-label">评价人：</label>
                <div class="layui-input-block">
                    <input type="text"  id="nicknames" autocomplete="off" class="layui-input">
                </div>
            </div>
             <div class="layui-inline">
                <label class="layui-form-label">评价时间：</label>
                <div class="layui-input-block">
                    <input type="text" id='create_times' autocomplete="off" class="layui-input">
                </div>
            </div> 
        </div>

        <div class="layui-form-item"> 
               <div class="layui-inline">
                <label class="layui-form-label">评价星级：</label>
                <div class="layui-input-block">
                   <input type="text" id="star" autocomplete="off" class="layui-input">
                </div>
            </div> 
             <div class="layui-inline">
                <label class="layui-form-label">评价状态：</label>
                <div class="layui-input-block">
                    <input type="text" id='eval_status' autocomplete="off" class="layui-input">
                </div>
            </div> 
        </div>    


          <div class="layui-form-item">   
           <div class="layui-inline">
                <label class="layui-form-label">评价内容：</label>
                <div class="layui-input-block"> 
                    <textarea id="contents" style="width: 500px;height: 150px;border: none;">
                        
                    </textarea>
                </div>
            </div> 
        </div> 
            <div class="layui-form-item">   
           <div class="layui-inline">
                <label class="layui-form-label">评价图片：</label>
                <div class="layui-input-block" id="images"> 
                    <img src="">
                </div>
            </div> 

        </div> 
      <div class="layui-form-item">
            <label class="layui-form-label">前台显示：</label>
            <div class="layui-input-block" id="editIsMenu">
                <input type="radio" name="is_display" value="1"  title="是"  >
                <input type="radio" name="is_display" value="0" title="否">
            </div>
        </div>
          <div class="layui-form-item layui-layout-admin">
            <div class="layui-input-block">
                <div class="layui-inline" style="left: 0;">
                    <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="editSubmit">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </div>
    </form>
</div> 
<!--导游信息详情-->
<!-- <div id="userDetail" style="display: none;padding:20px;">
    <div class="userDetailCen">
        <ul id="guide_ul">
            <li>
                <p class="p-user">订单信息：<span id=""></span></p>
            </li>
            <li>
                <p class="p-user">订单编号：<span id="order_sn"></span></p>
            </li>
            <li>
                <p class="p-user">支付方式：<span id="pay_type"></span></p>
            </li>
            <li>
            <p class="p-user"> 景点名称：<span id="tour_name"></span></p>
            </li>
            <li>
                <p class="p-user">取票人姓名：<span id="linkman"></span></p>
            </li>
            <li>
                <p class="p-user">取票人联系方式：<span id="tel"></span></p>
            </li>
            <li>
                <p class="p-user">购买的门票数：<span id="ticket_count"></span></p>
            </li>
            <li>
            <p class="p-user">门票使用日期：<span id="ticket_date"></span></p>
            </li>
            <li>
                <p class="p-user">订单状态：<span id="order_status"></span></p>
            </li>
            <li>
                <p class="p-user">订单价格：<span id="order_price"></span></p>
            </li>
            <li>
                <p class="p-user"> 下单时间：<span id="create_time"></span></p>
            </li>
        </ul>
    </div>
</div> -->

<script src="/static/layuiadmin/layui/layui.js"></script>
<script>
    layui.use('laydate', function(){
  var laydate = layui.laydate;  
  //日期范围
  laydate.render({
    elem: '#test6'
    ,range: true
  }); 
});
    layui.config({
        base: '/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','form','table','laydate','set'], function(){
        $ = layui.jquery;
        var table = layui.table
            ,admin = layui.admin
            ,element = layui.element
            ,layer = layui.layer
            ,laydate = layui.laydate
            ,form = layui.form;

        table.render({
            elem: '#test-table-operate'
            ,url: "{:url('Order/tourlist')}"
            ,height: 'full-100'
            ,cols: [[
                {field:'order_id',width:80,align:'center', title: 'ID'}
                ,{field:'order_sn',align:'center',title: '订单编号'}
                ,{field:'tour_name',align:'center',title: '景点名称'}
                ,{field:'linkman', align:'center', title: '取票人姓名'}
                ,{field:'ticket_date', align:'center', title: '使用日期'}
                ,{field:'order_status', align:'center', title: '订单状态'}
                ,{field:'order_price', align:'center', title: '订单价格'}
                ,{field:'create_time', align:'center', title: '下单时间'}
                ,{align:'center',width:350, title: '操作', toolbar: '#test-table-operate-barDemo'}
            ]]
            ,page:true
            ,limit:20
        });

        form.render(null,'component-form-group');

        laydate.render({
            elem: '#search_time'
        });
         //修改提交
        form.on('submit(editSubmit)', function(data){
            var loading = layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });
            $.ajax({
                url: "{:url('Appraise/appEdit')}",
                type: 'post',
                dataType: 'text',
                data: {data:data.field},
                success: function(info){
                    if (info === "1") {
                        layer.msg('修改成功',{icon:1,time:2000},function(){
                            window.location.reload();
                        });
                    }else{
                        layer.close(loading);
                        layer.msg('修改失败',{icon:2,time:1000})
                    }
                }
            })
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

        //监听工具条
        table.on('tool(test-table-operate)', function(obj){
            var data = obj.data;
            if(obj.event === 'showDetail'){
                var loading = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });
                var order_id = data.order_id;

                $.ajax({
                    url: "{:url('Order/tourOrderDetail')}",
                    type: 'post',
                    dataType: 'json',
                    data: {order_id:order_id},
                    success: function(data){
                        layer.close(loading);
                        if (data.code === 0) {
                            if(data.data.food_store_tag==""){
                                $('#tour_name').val('未设置');
                            }else{
                                $('#tour_name').val(data.data.tour_name);
                            }
                                if(data.data.order_sn ==""){
                                $('#order_sn').val('未设置');
                            }else{
                                $('#order_sn').val(data.data.order_sn);
                            }
                            if(data.data.pay_type){
                                  $('#pay_type').val(data.data.pay_type);
                            }else{ 
                                $('#pay_type').val('未设置');
                            }
                            if(data.data.order_status==''){
                                $('#order_status').val('未设置');
                            }else{
                                $('#order_status').val(data.data.order_status);
                            }
                            if(data.data.create_time==''){
                                $('#create_time').val('未设置');
                            }else{
                                $('#create_time').val(data.data.create_time);
                            }
                            if(data.data.tel==''){
                                $('#tel').val('未设置');
                            }else{
                                $('#tel').val(data.data.tel);
                            }
                            if(data.data.linkman==''){
                                $('#linkman').val('未设置');
                            }else{
                                $('#linkman').val(data.data.linkman);
                            }
                            if(data.data.order_price==''){
                                $('#order_price').val('未设置');
                            }else{
                                $('#order_price').val(data.data.order_price);
                            }
                            if(data.data.ticket_count==''){
                                $('#ticket_count').val('未设置');
                            }else{
                                $('#ticket_count').val(data.data.ticket_count);
                            }
                            if(data.data.ticket_date==''){
                                $('#ticket_date').val('未设置');
                            }else{
                                $('#ticket_date').val(data.data.ticket_date);
                            }
                            if(data.data.ticket_price==''){
                                $('#total_price').val('未设置');
                            }else{
                                $('#total_price').val(data.data.ticket_price);
                            }
                             if(data.data.ticket_date==''){
                                $('#ticket_date').val('未设置');
                            }else{
                                $('#ticket_date').val(data.data.ticket_date);
                            }
                             if(data.data.ticket_count==''){
                                $('#ticket_count').val('未设置');
                            }else{
                                $('#ticket_count').val(data.data.ticket_count);
                            }
                            var userDetailModal = layer.open({
                                title:'景点订单详情'
                                ,type: 1
                                ,shadeClose: true
                                ,area:['800px']
                                ,content: $('#userDetail')
                            });
                        }else{
                            layer.msg('获取信息失败',{icon:2,time:1000});
                        }


                    }
                })
            }  else if(obj.event === 'appDetail'){
                 var loading = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });
                var order_id = data.order_id;

                $.ajax({
                    url: "{:url('Appraise/getAppInfo')}",
                    type: 'post',
                    dataType: 'json',
                    data: {order_id:order_id,type:1},
                     success: function(data){
                        layer.close(loading);
                        if (data.code === 1) {
                            if(data.data.nickname==""){
                                $('#nicknames').val('未设置');
                            }else{
                                $('#nicknames').val(data.data.nickname);
                            } 
                             if(data.data.create_time==""){
                                $('#create_times').val('未设置');
                            }else{
                                $('#create_times').val(data.data.create_time);
                            } 
                             if(data.data.star==""){
                                $('#star').val('未设置');
                            }else{
                                $('#star').val(data.data.star);
                            } 
                            if(data.data.app_id){
                                $('#app_id').val(data.data.app_id);
                            }
                             if(data.data.eval_status==""){
                                $('#eval_status').val('未设置');
                            }else{
                                $('#eval_status').val(data.data.eval_status);
                            } 
                             if(data.data.content==""){
                                $('#contents').val('未设置');
                            }else{
                                $('#contents').val(data.data.content);
                            }   
                            
                             if(data.data.images.length>0){ 
                                 var imagehtml = "";
                                 $("#images").html('');
                                for(var i=0;i<data.data.images.length;i++){
                                     imagehtml += "<img style='margin-right:5px' width='100px' height='100px' src="+data.data.images[i]+">";
                                } 
                            }else{
                                 $('#images').html('未设置'); 
                            }
                           $("#images").append(imagehtml);

                          $("#editIsMenu input:radio[value ="+data.data.is_display+"]").attr('checked','true');
                            var userDetailModal = layer.open({
                                title:'景点评价详情'
                                ,type: 1
                                ,shadeClose: true
                                ,area:['800px']
                                ,content: $('#appDetail')
                            });
                        }else{
                            layer.msg(data.msg,{icon:2,time:1000});
                        }


                    }
                })
            } else if(obj.event === 'food_del'){
                layer.confirm('确认删除编号"' + data.order_sn + '"吗？', function(index){
                    var loading = layer.load(1, {
                        shade: [0.1,'#fff'] //0.1透明度的白色背景
                    });
                    $.ajax({
                        url: "{:url('Order/delGuide')}",
                        type: 'post',
                        dataType: 'json',
                        data: {id:data.order_id},
                        success: function(msg){
                            layer.close(loading);
                            if (msg.code == 0) {
                                obj.del();
                                layer.msg(msg.msg,{icon:1,time:1000});
                                layer.close(index);
                            }else{
                                layer.msg(msg.msg,{icon:2,time:1000});
                            }
                        }
                    });
                });
            }

        });

        var $ = layui.$, active = {
            addadmin: function() {
                window.location.href="{:url('Merchant/guideAdd')}";
            },
            searchUserButton:function(){
                var order_sn = $('#order_sn_').val();
                var tour_name = $('#tour_name_').val();
                var order_status = $("#order_status_").val();
                var create_time = $('#test6').val();
                table.reload('test-table-operate', {
                    where: {
                        order_sn:order_sn,
                        tour_name: tour_name,
                        order_status:order_status,
                        create_time:create_time
                    }
                    ,page: {
                        curr: 1 //重新从第 1 页开始
                    }
                });
                //return false;
            }
        };
        //绑定点击事件
        $('.test-table-operate-btn .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });

</script>


</body>
</html>